package com.k2data.endpoint;

import com.k2data.services.helloworld.HelloWorldPortType;
import com.k2data.types.helloworld.Greeting;
import com.k2data.types.helloworld.ObjectFactory;
import com.k2data.types.helloworld.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jws.WebService;


/**
 * Created by luoqifei on 17-1-6.
 */
@WebService(endpointInterface = "com.k2data.services.helloworld.HelloWorldPortType", targetNamespace = "http://k2data.com/services/helloworld")
public class HelloWorldImpl implements HelloWorldPortType {

    private static final Logger LOGGER = LoggerFactory.getLogger(HelloWorldImpl.class);
    @Override
    public Greeting sayHello(Person request) {
        LOGGER.info(
                "Endpoint received person=[firstName:{},lastName:{}]",
                request.getFirstName(), request.getLastName());
        String greeting = "Hello " + request.getFirstName() + " " + request.getLastName() + "!";
        ObjectFactory factory = new ObjectFactory();
        Greeting response = factory.createGreeting();
        response.setGreeting(greeting);

        LOGGER.info("Endpoint sending greeting=[{}]", response.getGreeting());
        return response;
    }
}
